# Maintainer: George Rawlinson <george@rawlinson.net.nz>
# Contributor: Max Zhao <alcasa dot mz at gmail dot com>
# Contributor: Leonard König <leonard.r.koenig at googlemail dot com>

pkgname=endless-sky
pkgver=0.9.16.1
pkgrel=1
pkgdesc='A sandbox-style space exploration and combat game'
arch=('loong64' 'x86_64')
url='https://endless-sky.github.io/'
# licenses obtained via following script:
# grep "^License:" copyright | sed -e "s/License: //" -e "s/ /-/" | sort | uniq
license=(
  'GPL3'
  'custom:CC-BY-3.0'
  'custom:CC-BY-4.0'
  'custom:CC-BY-NC-3.0'
  'custom:CC-BY-SA-3.0'
  'custom:CC-BY-SA-4.0'
  'custom:public-domain'
)
depends=(
  'gcc-libs'
  'openal'
  'libpng'
  'glew'
  'hicolor-icon-theme'
  'libjpeg-turbo'
  'sdl2'
  'libmad'
  'util-linux-libs'
)
makedepends=('git' 'scons')
optdepends=(
  'endless-sky-high-dpi: high resolution graphics assets'
)
options=('debug')
_commit='d930b95c14119a74c6ffaadbe14bfd67a679af81'
source=("$pkgname::git+https://github.com/endless-sky/endless-sky#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags --exclude 'continuous' | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # binary is installed to /usr/games instead of /usr/bin
  sed -i 's:games", sky:bin", sky:' SConstruct
}

build() {
  cd "$pkgname"

  scons -j "$(nproc)"
}

package() {
  cd "$pkgname"

  scons \
    DESTDIR="$pkgdir" \
    PREFIX=/usr \
    install

  # license
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" copyright
}
